<?php
class Json extends MY_Controller  {
	
	public function index()
	{
		//echo "---------------------------------".$_POST['keyword'];
		echo json_encode( $this->postalcode->limitAndLike(20,0,"postal_code",$_POST['keyword']));
	}
	
	public function zipcodes()
	{
		echo json_encode( $this->postalcode->limitAndLike(20,0,"postal_code",$_REQUEST['keyword']));
	}
	
	public function staff(){
			echo json_encode( $this->user->searchStaff(20,0,$_REQUEST['keyword']));
	
	}
	
	public function saveitemsinset(){
		$set = $_REQUEST['currentSet'];
		$item = $_REQUEST['currentItem'];
		$msg = array('message' => "message");
		
		
		$this->set_items->productsetid = $_REQUEST['currentSet'];
		$this->set_items->itemid = $_REQUEST['currentItem'];
		$this->set_items->itemquantity = $_REQUEST['itemquantity'];
		$this->set_items->denomination = $_REQUEST['denomination'];
		
		$this->set_items->insert();
		
		echo json_encode($msg);
	}
	
	public function customerverification(){
	      
		  $surname =   $_REQUEST['_surname'];
	      $firstname = $_REQUEST['_firstname'];
	      $zipcode =   $_REQUEST['_zipcode'];
	      $telephone = $_REQUEST['_telephone'];
      	  $streetname =  $_REQUEST['_streetname'];
		  $streetnumber =  $_REQUEST['_streetnumber'];
		  $apartmentname =  $_REQUEST['_apartmentname'];
		  $roomnumber =  $_REQUEST['_roomnumber'];
		  $searchingoption = $_REQUEST['_searchingoption'];
		  
	      $clientRecord =  $this->client->searchClientInformation(20, 0 ,  $firstname , $surname , $telephone , 
	      $zipcode, $streetname , $streetnumber , $apartmentname , $roomnumber , $searchingoption);
	      //staff code
	      if($clientRecord == null){
	      	//valid itong client na ito
	      }else if($clientRecord != null && sizeof($clientRecord) == 1){
	      	//verify if this client already have more than 3 refused orders
	      		//return an error message
	      	//search last order of this client
	      		//if last record was more than 2months
	      			//client is valid
	      		//else 
	      			//verify if current assigned STAFF is assigned o this client
	      			
	      		
	      }else if($clientRecord != null && sizeof($clientRecord) > 1){
	      	//display all this Records for the encoder to select a client
	      }
	      
	      
	      
		  echo json_encode($clientRecord); 
	      
		
		
	}
		
}